<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
</head>
<body>
<div>
    javascript
    <p id="p1">javascript</p>
    <div>jQuery</div>
    <h5>PHP</h5>
    <ul>
        <li>1L</li>
        <li>2L</li>
        <li>3L</li>
    </ul>
</div>
<script type="text/javascript">
    //var a1=document.getElementById("p1");
    //1. 获取第一个DIV的子节点。2. 使用for遍历每个节点。3. 输出相应节点的属性。
    var a = document.getElementsByTagName("div")[0].childNodes;
    for (var i = 0; i < a.length; i++) {
        document.write("第" + i + "节点属性:" + a[i].nodeName + "、" + a[i].nodeType + "、" + a[i].nodeValue + "<br>");
    }
    //document.write(a[0]+"<br>");

    var x = document.getElementsByTagName("ul")[0].childNodes;
    document.write("ul子节点个数:" + x.length + "<br>");
    document.write("节点类型:" + x[0].nodeType);
</script>
</body>
</html>